import 'swiper/dist/css/swiper';
import  Swiper from 'swiper';

const ReactSwiper = React.createClass({
    componentDidMount(){
        const _self = this;
        setTimeout( () => { _self.initSwiper() });
    },
    componentWillUnmount(){
       this.swiper.destroy();
    },
    swiper:null,
    initSwiper(){
       const elemet = this.refs.swiper;
       this.swiper  = new Swiper( elemet , {
            pagination : '.swiper-pagination',
            loop:false,
            autoplay: 5000,
            lazyLoading : true,
            autoplayDisableOnInteraction:false
        });
    },
    render:function(){
       return(
           <div className="swiper-container" ref="swiper">
               <div className="swiper-wrapper">
                   {this.props.children}
               </div>
           </div>
       )
    }
});

module.exports = ReactSwiper;
